package com.briup.jz.web.controller;

import com.briup.jz.bean.Order;
import com.briup.jz.service.IOrderService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("order")
public class OrderController {

   @Autowired
    private IOrderService iOrderService ;

    @PostMapping("saveorupdate")
    public Message saveorupdate(Order order){
        iOrderService.saveOrUpdate(order);
        return MessageUtil.success("操作成功");
    }
    @GetMapping("query")
    public  Message query(Long id,Long cusid,Long empid){
        List<Order> orders = iOrderService.query(id,cusid,empid);
        return MessageUtil.success(orders);
    }

    @GetMapping("delete")
    public  Message delete(Long id){
        iOrderService.deleteById(id);
        return MessageUtil.success("操作成功");
    }
}
